﻿using Ease.EaseDialog.Runtime;
using Ease.EaseDialog.Runtime.Data;
using Ease.EaseNode.Editor.NodeView;
using Unity.VisualScripting;
using UnityEngine.UIElements;

namespace Ease.EaseDialog.Editor
{
    public class DialogSoInspectorView : BaseSoInspectorView<DialogDataInspector>, IUpdateSelection
    {
        public new class UxmlFactory : UxmlFactory<DialogSoInspectorView, UxmlTraits>
        {
        }

        private BaseEaseNode lastEaseNode;

        public void OnUpdateSelection(BaseEaseNode easeNode)
        {
            lastEaseNode = easeNode;
            if (easeNode != null)
                so.Data = easeNode.State.Data as BaseDialogData;
            else
                so.Data = null;
        }

        protected override void OnEnteredEditorMode()
        {
            base.OnEnteredEditorMode();
            OnUpdateSelection(lastEaseNode);
        }
    }
}